package lab04.test03;

public class Print extends Thread {
     public  Print(String name){
         setName(name);
     }
     public void run(){
         int i = 0;
         while (i++ < 5) {
                 System.out.print(getName() + " ");
             try {
                 sleep((int)(Math.random() * 1000));//通过这个算法来睡眠线程，交出控制权
             }catch (Exception e){
                 e.printStackTrace();
             }
         }
     }
}


